package homework.Thirty;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class EventTest3 implements ActionListener {

    public static void main(String[] args) {
        EventTest3 eventTest3=new EventTest3();
        Frame frame=new Frame("测试窗口");
        frame.setSize(new Dimension(640,640));
        frame.setLayout(new BorderLayout());
        Panel panel=new Panel();
        Button myButton2=new Button("Left Button");
        myButton2.addActionListener(eventTest3);
        panel.add(myButton2);
        frame.add(panel);
        frame.setVisible(true);

    }

    @Override
    public void actionPerformed(ActionEvent e){
        String arg=e.getActionCommand();
        if ("Left Button".equals(arg)){
            System.out.println("Press Left Button");
        }
    }
}
